using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Diagnostics;

namespace Blazing.Web.Util
{
    public class SiteMapHelper
    {
        /// <summary>
        /// Fetches a SiteMapNode by it's 'ID' property
        /// </summary>
        public static SiteMapNode GetSiteNode(string nodeId)
        {
            SiteMapNode root = SiteMap.RootNode;
            SiteMapNode retval = null;
            foreach (SiteMapNode node in root.GetAllNodes())
            {
                string id = node["ID"];

                if (!string.IsNullOrEmpty(id) && id.Equals(nodeId))
                {
                    retval = node;
                    break;
                }
            }

            Debug.Assert(retval != null);

            return retval;
        }
    }
}
